(function(window) {
	var vm;
	var shopId = "";
	var devSN = "";
	var userName = "";

	function PulldownRefresh(isPulldownRefresh) {
		var self = this;
		isPulldownRefresh = isPulldownRefresh === undefined ? true : isPulldownRefresh;
		setTimeout(function() {
			isPulldownRefresh && self.endPullDownToRefresh();
		}, 2000);
		v3StaMonitor.getClientValue(shopId, function(code, data) {
			if(code === 0 && data.length !== 0) {
				data.forEach(function(item) {
					if(item.clientRxBytes > 1048576 * 1024) {
						item.clientRxBytes = (item.clientRxBytes / (1048576 * 1024)).toFixed(2) + 'G'
					} else if(1024 * 1024 < item.clientRxBytes < 1048576 * 1024) {
						item.clientRxBytes = (item.clientRxBytes / (1024 * 1024)).toFixed(2) + 'M'
					} else {
						item.clientRxBytes = (item.clientRxBytes / 1024).toFixed(2) + 'K'
					}
				})
				if(data.length > 7) {
					for(var i = 0; i < 7; i++) {
						vm.clientTop5List.push(data[i]);
					}
				} else {
					vm.clientTop5List = data;
				}
			} else {
				vm.clientTop5List = [{
					'clientMAC': '无终端',
					'clientRxBytes': '0'
				}];
			}
		})
		v3PortalMonitor.getAuthUserCount(devSN, function(code, data) {
			if(code === 0) {
				vm.terminalAuth = data.portalusercount;
			}
		});
		
		
	}

	function mounted() {
		vm = this;

		$.plusReady(function() {
			shopId = $.util.getShopId();
			devSN = $.util.getDevSN();
			userName = dataManager.getUserName();
			PulldownRefresh(false);
			$('.mui-scroll-wrapper').scroll({
				indicators: true, //是否显示滚动条
				bounce: false,
				deceleration: 0.0005
			});

			$("#manager-scroll").pullToRefresh({
				down: {
					//					callback: managerPagePulldownRefresh
				}
			});
		});
	}

	window.client = {
		mounted: mounted,
		data: {
			terminalAuth: 0,
			devName: "",
			devSN: "",
			clientTop5List: []
		},
		methods: {
			allClientList: function(){
				commonTool.openWindow('smallBie/allClientList-main.html', 'mallBie/allClientList-main.html');
			},
		}
	};
})(window);